package entity

import (
	dom "a-common/domain"
	// "github.com/vmihailenco/msgpack"
)

const (
	Balance_Amount   = "1" // 金额
	Balance_Integral = "2" // 积分
)

// AppBalance 系统账户表
type AppBalance struct {
	BalanceId      int64  `xorm:"pk autoincr notnull"`        // 账户ID
	BalanceNo      string `xorm:"varchar(30) notnull unique"` // 账户账号
	BalanceType    string `xorm:"varchar(1) notnull"`         // 账户类型
	Userid         int64  `xorm:"varchar(30) notnull"`        // 用户ID
	ChangeNum      int64  `xorm:"default(0) notnull"`         // 变更额度
	OriginalNum    int64  `xorm:"default(0) notnull"`         // 原来额度
	CurrentNum     int64  `xorm:"default(0) notnull"`         // 当前额度
	Status         string `xorm:"varchar(1)"`                 // 帐号状态（1正常 0停用）
	dom.BaseStruct `xorm:"extends"`
}

// AppBalanceVo 映射
type AppBalanceVo struct {
	BalanceId   int64  `json:"balanceId,omitempty" xorm:"pk"`
	BalanceNo   string `json:"balanceNo,omitempty"`
	BalanceType string `json:"balanceType,omitempty"`
	Userid      int64  `json:"userid"`
	ChangeNum   int64  `json:"changeNum"`
	OriginalNum int64  `json:"originalNum"`
	CurrentNum  int64  `json:"currentNum"`
	Status      string `json:"status,omitempty"`
}

// AppBalancePageVo 页面
type AppBalancePageVo struct {
	AppBalanceVo `xorm:"extends"`
	dom.BaseJson `xorm:"extends"`
}

// BalanceDto 传输
type AppBalanceDto struct {
	AppBalancePageVo
	Params dom.ParamTime `json:"params"`
	dom.PageDto

	RoleId     int64   `json:"roleId" xorm:"-"`
	BalanceIds []int64 `json:"userIds" xorm:"-"`
	RoleIds    []int64 `json:"roleIds" xorm:"-"`
	PostIds    []int64 `json:"postIds" xorm:"-"`

	OldPassword string `json:"oldPassword" xorm:"-"`
	NewPassword string `json:"newPassword" xorm:"-"`
}

func (m *AppBalanceDto) Validator() error {
	if m.PageNum < 1 {
		m.PageNum = 1
	}
	if m.PageSize < 1 {
		m.PageSize = 10
	}
	return nil
}

// AppBalanceExportVo 导出
type AppBalanceExportVo struct {
	BalanceId   int64    `excel:"name:账户ID;" xorm:"pk"`
	BalanceName string   `excel:"name:登录名称;"`
	NickName    string   `excel:"name:账户名称;"`
	Email       string   `excel:"name:账户邮箱;"`
	Phonenumber string   `excel:"name:手机号码;"`
	Sex         string   `excel:"name:账户性别;replace:0_男,1_女,2_未知;"`
	Status      string   `excel:"name:帐号状态;replace:0_正常,1_停用;"`
	LoginIp     string   `excel:"name:最后登录IP;"`
	LoginDate   dom.Time `excel:"name:最后登录时间;"`
	DeptName    string   `excel:"name:部门名称;"`
	Leader      string   `excel:"name:部门负责人;"`
}

// AppBalanceImportVo 导入
type AppBalanceImportVo struct {
	BalanceId   int64  `json:"userId,omitempty" excel:"name:账户ID;" xorm:"pk"`
	BalanceName string `json:"userName,omitempty" excel:"name:登录名称;"`
	NickName    string `json:"nickName,omitempty" excel:"name:账户名称;"`
	Email       string `json:"email,omitempty" excel:"name:账户邮箱;"`
	Phonenumber string `json:"phonenumber,omitempty" excel:"name:手机号码;"`
	Sex         string `json:"sex" excel:"name:账户性别;replace:0_男,1_女,2_未知;"`
	Status      string `json:"status,omitempty" excel:"name:帐号状态;replace:0_正常,1_停用;"`
}

// AppBalanceSelectListVo 账户下拉列表
type AppBalanceSelectListVo struct {
	BalanceId   int64  `json:"userId,omitempty" xorm:"pk"`
	BalanceName string `json:"userName,omitempty"`
}
